using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace PreguntaAlExperto.ObjectMapper.Helper
{

    public class EncryptionServices
    {
        /// <summary>
        /// Encode string to MD5 string
        /// </summary>
        /// <param name="DataString">Original string data</param>
        /// <returns>Base 64 encrypted string</returns>
        public string EncodeStringToMD5(string DataString)
        {
            Byte[] originalBytes;
            Byte[] encodedBytes;

            MD5 md5 = new MD5CryptoServiceProvider();
            originalBytes = ASCIIEncoding.Default.GetBytes(DataString);
            encodedBytes = md5.ComputeHash(originalBytes);

            return Convert.ToBase64String(encodedBytes);
        }
    }
}
